﻿using BrnMall.Manager.Domain.PC;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BrnMall.Manager.Manager.PC
{
    public static class PcConfigManager
    {
        /// <summary>
        /// 添加PC网站配置
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool Add(PcConfig model)
        {
            object obj = null;
            using (var db = new QDMallDatabase())
            {
                obj = db.Insert(model);
            }
            if (obj != null)
                return true;
            return false;
        }

        /// <summary>
        /// 更新PC网站配置
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool Update(PcConfig model)
        {
            int count = 0;
            using (var db = new QDMallDatabase())
            {
                count = db.Update(model);
            }
            return count > 0;
        }

        /// <summary>
        /// 获取单条PC网站配置
        /// </summary>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public static PcConfig GetByStoreId(int storeId)
        {
            if (storeId < 1) return null;
            using (var db = new QDMallDatabase())
            {
                return db.SingleOrDefault<PcConfig>(string.Format("select top 1 * from PC_Config where storeId={0}", storeId));
            }
        }
    }
}